package cn.tedu.spring.diobj;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 测试类
 */
public class BeanTest {
    /**
     * 测试引用外部bean
     */
    @Test
    public void setBean(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean-diobj.xml");
        Emp emp=context.getBean("emp",Emp.class);
        System.out.println(emp);
    }
    /**
     * 测试引用内部bean
     */
    @Test
    public void setBean2(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean-diobj.xml");
        Emp emp=context.getBean("emp2",Emp.class);
        System.out.println(emp);
    }
    /**
     * 测试级联属性赋值
     */
    @Test
    public void setBean3(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean-diobj.xml");
        Emp emp=context.getBean("emp3",Emp.class);
        System.out.println(emp);
    }
}
